// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   ConnectionManager.java

package org.fiel.commons.jdbc;

import java.io.PrintStream;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.*;
import javax.sql.DataSource;

public class ConnectionManager
{

    private ConnectionManager()
    {
        try
        {
            ctx = getInitialContext();
            dataSource = (DataSource)ctx.lookup("java:comp/env/jdbc/FielDB");
        }
        catch(NamingException ne)
        {
            System.out.println("Error al inicializar ConnectionManager");
            ne.printStackTrace();
        }
    }

    public static synchronized ConnectionManager getInstance()
    {
        if(aConnectionManagerSingleton == null)
            aConnectionManagerSingleton = new ConnectionManager();
        return aConnectionManagerSingleton;
    }

    public Connection getConnection()
        throws SQLException
    {
        return getDataSource().getConnection();
    }

    private static Context getInitialContext()
        throws NamingException
    {
        return new InitialContext();
    }

    private DataSource getDataSource()
    {
        return dataSource;
    }

    private static ConnectionManager aConnectionManagerSingleton;
    private static final String dataSourceName = "java:comp/env/jdbc/FielDB";
    private DataSource dataSource;
    private Context ctx;
}
